SceneMaxZdepth
SceneMaxZdepth Zdepth
 
Parameters:

    Zdepth = The far clipping plane along the z axis
Returns: NONE
 

      SceneMaxZdepth sets max Z depth allowed in the scene buffer.




FACTS:


      * The Scene Buffer can only handle positive Z depths from zero to it's SceneMaxZdepth





Mini Tutorial:


      This example creates a type of soft 3D scene, where it projects a set of pixels in 3d space. So pixels have z depth. The viewer then zooms in and out where pixels behind or beyond the max z depth are culled from the scene.


  
; Create camera 1.
  CreateCamera 1
  CameraCls 1,off
  
  
; max 3D Space  depth
  ZRange=20000
  
; Max Scene Depth  0 to 5000
  
  SceneDepth=5000
  SceneMaxZdepth SceneDepth+1
  
  
; perspective projection
  ProjectionX=300
  ProjectionY=300
  
; Depth Shading
  
  DepthScaler#=150.0/SceneDepth
  
  
  
  
; Start a Do/loop
  Do
     Cls RGB(0,0,0)
     
   ; Tell PB to capture the following GFX commands
   ; to the scene Buffer
     CaptureToScene
     ClsScene
     
   ; Get the camera X & Y position
     CamX=GetCameraX(1)
     CamY=GetCameraY(1)
     
   ; reset the rnd number sequence
     Randomize 056
     
   ;
     For lp=0 To 5000
        x     =RndRange(-2000,2000)-CamX
        y     =RndRange(-2000,2000)-CamY
        
        z     =RndRange(1,Zrange)-CamZ
        ThisRGB=RndRGB()
        
        If Z>-1
           If Z<=SceneDEpth
              CaptureDepth z
              
            ; shade the Colour of this pixel
              ThisRGB=RGBFade(ThisRGB,Depthscaler#*(SceneDepth-Z))
              
            ; Draw a captured dot to the scenebuffer
              DotC 400+(x*ProjectionX)/z,300+(y*ProjectionY)/z,ThisRGB
              
           EndIf
           
        EndIf
     Next
     
   ; Draw the camera
     DrawCamera 1
     
     Text 0,0,FPS()
     
     camZ=(ZRange/2)+SinRadius(angle#,ZRange/3)
     Angle#=WrapAngle(angle#,0.10)
     
     
     Sync
  Loop
  
  







 
Related Info: CameraBasics | CaptureToScene | ClsScene | CreateCamera | DrawCamera | SceneCacheSize | SceneSortMethod :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com